<template>
	<!-- <image src="https://hzybucket.obs.cn-south-1.myhuaweicloud.com/we_chat/top-bg.png" class="bg-color" mode="aspectFill"></image> -->
	<!--  refresher-only @onRefresh="onRefresh"    只要下拉 -->
	<!-- :bg-color="scrollTop > 100 ? 'rgba(255,255,255,1)' : 'rgba(255,255,255,0)'" -->
	<z-paging ref="paging" refresher-only @scroll="pagScroll" @onRefresh="onRefresh">
		<!-- 之后-vue3 -->
		<template #top>
			<!--  :bgColor="scrollTop > 100 ? '#fff' : 'rgba(0,0,0,0)'" -->
			<uv-navbar @leftClick="leftClick" :fixed="false" title="项目进度"></uv-navbar>
		</template>
		<block #refresher="{ refresherStatus }">
			<custom-refresher :status="refresherStatus" />
		</block>
		<!-- 内容 -->
		<view class="content-box">
			<view class="top-box">
				<view class="top-round"></view>
				<view class="bottom-round"></view>
				<view class="top-box-content">
					<view class="title-box">
						<view class="title ellipsis">{{ dataObj.project_name || '待完善' }}</view>
						<block>
							<view class="btn" v-if="dataObj.display_status == 10">待启动</view>
							<view class="btn" v-if="dataObj.display_status == 15">待勘场</view>
							<view class="btn" v-if="dataObj.display_status == 18">待勘场出图</view>
							<view class="btn" v-if="dataObj.display_status == 20">待方案设计</view>
							<view class="btn" v-if="dataObj.display_status == 25">待报价</view>
							<view class="btn" v-if="dataObj.display_status == 30">洽谈中</view>
							<view class="btn" v-if="dataObj.display_status == 40">已签约</view>
							<view class="btn" v-if="dataObj.display_status == 45">施工中</view>
							<view class="btn" v-if="dataObj.display_status == 50">已完工</view>
							<view class="btn" v-if="dataObj.display_status == 55">待结算</view>
							<view class="btn" v-if="dataObj.display_status == 60">款项付清</view>
							<view class="btn" v-if="dataObj.display_status == 70">项目取消</view>
						</block>
					</view>
					<view class="top-box-content-data iconfont icon-zidongbianhao">{{ dataObj.project_number }}</view>
					<view class="top-box-content-data iconfont icon-dingwei">{{ dataObj.area + dataObj.address }}</view>

					<view class="top-box-content-btn-box">
						<uv-button @click="navToDetail">
							<text class="iconfont icon-wj-wj-2"></text>
							项目详情
						</uv-button>
					</view>
				</view>
			</view>
		</view>

		<!-- 项目流程 -->
		<view class="project-box">
			<view class="project-title">项目进度</view>
			<view class="tab-box"><uv-tabs :list="tabList" @click="tabClick"></uv-tabs></view>
			<logListCom :field_permissions="field_permissions" :logList="logList"></logListCom>
		</view>

		<template #bottom>
			<view class="bottom-box ios">
				<!-- 客户总监操作 -->
				<uv-button
					v-if="dataObj.status == 1000 && userInfo.position_id == 1"
					@click="fpkhjlShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 210rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="分配客户经理"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1015 && (userInfo.position_id == 2 || userInfo.position_id == 12)"
					@click="scsjtShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 190rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="上传设计图"
				></uv-button>

				<!-- ------------------------------需要勘场------------------------------- -->
				<!-- 客户经理操作 -->
				<uv-button
					v-if="dataObj.status == 1020 && userInfo.position_id == 2"
					@click="tjkcpzShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 220rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="提交勘场凭证"
				></uv-button>
				<!-- 财务操作 -->
				<uv-button
					v-if="dataObj.status == 1025 && userInfo.position_id == 9"
					@click="kcfdkqrShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 220rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="勘场费打款确认"
				></uv-button>
				<!-- 工程部经理 -->
				<uv-button
					v-if="dataObj.status == 1030 && userInfo.position_id == 6"
					@click="fkgcjlShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 260rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="分配勘场工程经理"
				></uv-button>
				<!-- 工程经理 -->
				<uv-button
					v-if="dataObj.status == 1045 && userInfo.position_id == 7"
					@click="tjkcbgShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 220rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="提交勘场报告"
				></uv-button>
				<!-- 设计师 -->
				<!--  -->
				<uv-button
					v-if="dataObj.status == 1055 && userInfo.position_id == 3"
					@click="sckczlShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 220rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="上传勘场资料"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1060 && (userInfo.position_id == 2 || userInfo.position_id == 12)"
					@click="scsjtShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 190rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="上传设计图"
				></uv-button>
				<!-- ------------------------------需要勘场结束------------------------------- -->

				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1065 && userInfo.position_id == 2"
					@click="sqbjShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 150rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="申请报价"
				></uv-button>
				<!-- 造价主管 -->
				<uv-button
					v-if="dataObj.status == 1070 && userInfo.position_id == 4 && !dataObj.cost_estimator_id"
					@click="fpzjyShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="分配造价员"
				></uv-button>
				<!-- 工程部经理 -->
				<uv-button
					v-if="(dataObj.status == 1070 || dataObj.status == 1080 || dataObj.status == 1090) && userInfo.position_id == 6 && !dataObj.engineering_manager_id"
					@click="fkgcjlShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 260rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="分配施工工程经理"
				></uv-button>
				<!-- 工程经理(施工工程经理) -->
				<uv-button
					v-if="dataObj.status == 1090 && userInfo.position_id == 7 && dataObj.engineering_manager_id && dataObj.engineering_manager_id == userInfo.id"
					@click="shzjdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="审核造价单"
				></uv-button>
				<!-- 造价主管 -->
				<uv-button
					v-if="dataObj.status == 1092 && userInfo.position_id == 4"
					@click="shzjdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="审核造价单"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1095 && userInfo.position_id == 2"
					@click="dkbjShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 150rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="对客报价"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1095 && userInfo.position_id == 2"
					@click="htzbjShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 190rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="回退至报价单"
				></uv-button>
				<!-- 客户总监 -->
				<uv-button
					v-if="dataObj.status == 1100 && userInfo.position_id == 1"
					@click="shdkbjdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 240rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="审核对客报价单"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					@click="tjqdhyShow = true"
					v-if="dataObj.status == 1102 && userInfo.position_id == 2"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="提交签订合约"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1105 && userInfo.position_id == 2"
					@click="tjyfkpzShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 220rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="提交预付款凭证"
				></uv-button>
				<!-- 财务 -->
				<uv-button
					v-if="dataObj.status == 1110 && userInfo.position_id == 9"
					@click="yfkdkqrShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 240rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="预付款打款确认"
				></uv-button>
				<!-- 工程监理 -->
				<uv-button
					v-if="dataObj.status == 1115 && userInfo.position_id == 8"
					@click="qrkssgShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 240rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="确认开始施工"
				></uv-button>

				<!-- -----------------------------------节点验收过程（开始）------------------------------------ -->
				<!-- 工程经理 -->
				<uv-button
					v-if="
						(dataObj.status == 1118 || dataObj.status == 1120) &&
						userInfo.position_id == 7 &&
						projectNodesItem.node_status == 1 &&
						dataObj.engineering_manager_id == userInfo.id
					"
					@click="jdysShouwFunc"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="节点验收"
				></uv-button>
				<!-- 工程监理 -->
				<uv-button
					v-if="dataObj.status == 1120 && userInfo.position_id == 8 && projectNodesItem.node_status == 2"
					@click="jdysshShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="节点验收审核"
				></uv-button>
				<!-- 工程部经理 -->
				<uv-button
					v-if="dataObj.status == 1120 && userInfo.position_id == 6 && projectNodesItem.node_status == 3"
					@click="jdysshShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="节点验收审核"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1120 && userInfo.position_id == 2 && projectNodesItem.node_status == 4"
					@click="tjjdkpzShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 240rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="提交进度款凭证"
				></uv-button>
				<!-- 财务 -->
				<uv-button
					v-if="dataObj.status == 1120 && userInfo.position_id == 9 && projectNodesItem.node_status == 5"
					@click="jdkdkqrShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 240rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="进度款打款确认"
				></uv-button>

				<!-- -----------------------------------节点验收过程(结束)------------------------------------ -->

				<!-- 工程监理 -->
				<uv-button
					v-if="(dataObj.status == 1120 || dataObj.status == 1118) && userInfo.position_id == 8"
					@click="sgjlShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="施工记录"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1125 && userInfo.position_id == 2"
					@click="qrzjxShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="确认增减项"
				></uv-button>
				<!-- 工程经理 -->
				<uv-button
					v-if="dataObj.status == 1135 && userInfo.position_id == 7 && dataObj.engineering_manager_id == userInfo.id"
					@click="shjsdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="审核结算单"
				></uv-button>
				<!-- 造价主管 -->
				<uv-button
					v-if="dataObj.status == 1138 && userInfo.position_id == 4"
					@click="shjsdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="审核结算单"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1140 && userInfo.position_id == 2"
					@click="tjwkpzShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="提交尾款信息"
				></uv-button>
				<!-- 客户经理 -->
				<uv-button
					v-if="dataObj.status == 1140 && userInfo.position_id == 2"
					@click="xmhtzjsdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 220rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="回退至结算单"
				></uv-button>
				<!-- 客户总监 -->
				<uv-button
					v-if="dataObj.status == 1145 && userInfo.position_id == 1"
					@click="shwkxxShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="审核尾款信息"
				></uv-button>
				<!-- 财务 -->
				<uv-button
					v-if="dataObj.status == 1147 && userInfo.position_id == 9"
					@click="qrwkxxShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="确认尾款信息"
				></uv-button>
				<!-- 管理员 -->
				<uv-button
					@click="adminHtShow = true"
					v-if="userInfo.position_id == 10 && dataObj.survey_site != 0 && dataObj.status < 1150"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 200rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="回退项目进度"
				></uv-button>
				<!-- 客户 -->
				<uv-button
					@click="khxmpjShow = true"
					v-if="dataObj.status == 1150 && userInfo.position_id == 12"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
					customStyle="width: 180rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
					type="primary"
					text="项目评价"
				></uv-button>

				<!-- 尾款结算之前，客户经理一直存在的操作 -->
				<block v-if="dataObj.status != 1500 && dataObj.status < 1150 && dataObj.status">
					<uv-button
						v-if="dataObj.status != 1145 && userInfo.position_id == 2"
						@click="dkrzShow = true"
						customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
						customStyle="width: 150rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
						type="primary"
						text="对客日志"
					></uv-button>
					<!-- <uv-button
            v-if="dataObj.status != 1145 && dataObj.status != 1140 && dataObj.status != 1095 && userInfo.position_id == 2"
            @click="goToDetail" customTextStyle="font-weight: 400;font-size: 28rpx;color: #FFFFFF;"
            customStyle="width: 150rpx;height: 80rpx;background: #3B75FF;border-radius: 16rpx;margin-bottom:30rpx;"
            type="primary" text="项目完善"></uv-button> -->
					<uv-button
						v-if="dataObj.status != 1145 && dataObj.status != 1140 && userInfo.position_id == 2"
						@click="xmqxShow = true"
						customTextStyle="font-weight: 400;font-size: 28rpx;color: #8F8F8F;"
						customStyle="width: 150rpx;height: 80rpx;background: #FFFFFF;border-radius: 16rpx;border: 2rpx solid #E3E3E3;margin-bottom:30rpx;"
						text="项目取消"
					></uv-button>
				</block>
				<!-- 工程经理 -->
				<uv-button
					v-if="dataObj.status < 1092 && userInfo.position_id == 7 && dataObj.engineering_manager_id && dataObj.engineering_manager_id == userInfo.id"
					@click="jjjdShow = true"
					customTextStyle="font-weight: 400;font-size: 28rpx;color: #8F8F8F;"
					customStyle="width: 150rpx;height: 80rpx;background: #FFFFFF;border-radius: 16rpx;border: 2rpx solid #E3E3E3;margin-bottom:30rpx;"
					text="拒绝接单"
				></uv-button>
			</view>
		</template>
	</z-paging>
	<!-- 分配客户经理 -->
	<fpkhjlCom :show="fpkhjlShow" @close="fpkhjlShow = false" @onSuccess="onSuccess" :dataObj="dataObj"></fpkhjlCom>
	<!-- 提交勘场凭证 -->
	<tjkcpzCom :show="tjkcpzShow" @close="tjkcpzShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></tjkcpzCom>
	<!-- 对客日志 -->
	<dkrzCom :show="dkrzShow" @close="dkrzShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></dkrzCom>
	<!-- 勘场费确认 -->
	<kcfdkqrCom
		:field_permissions="field_permissions"
		:shkxpzData="shkxpzData"
		:show="kcfdkqrShow"
		@close="kcfdkqrShow = false"
		:dataObj="dataObj"
		@onSuccess="onSuccess"
	></kcfdkqrCom>
	<!-- 分配工程经理 -->
	<fkgcjlCom :show="fkgcjlShow" @close="fkgcjlShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></fkgcjlCom>
	<!-- 提交勘场报告 -->
	<tjkcbgCom :show="tjkcbgShow" @close="tjkcbgShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></tjkcbgCom>
	<!-- 上传勘场资料 -->
	<sckczlCom :show="sckczlShow" @close="sckczlShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></sckczlCom>
	<!-- 上传设计图 -->
	<scsjtCom :show="scsjtShow" @close="scsjtShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></scsjtCom>
	<!-- 申请报价 -->
	<sqbjCom :show="sqbjShow" @close="sqbjShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></sqbjCom>
	<!-- 分配造价员 -->
	<fpzjyCom :show="fpzjyShow" @close="fpzjyShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></fpzjyCom>
	<!-- 审核造价单 -->
	<shzjdCom :field_permissions="field_permissions" :show="shzjdShow" @close="shzjdShow = false" :zjData="zjData" :dataObj="dataObj" @onSuccess="onSuccess"></shzjdCom>
	<!-- 拒绝接单 -->
	<jjjdCom :show="jjjdShow" @close="jjjdShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></jjjdCom>
	<!-- 对客报价 -->
	<dkbjCom :show="dkbjShow" @close="dkbjShow = false" :zjData="zjData" :dataObj="dataObj" @onSuccess="onSuccess"></dkbjCom>
	<!-- 回退至报价 -->
	<htzbjCom :show="htzbjShow" @close="htzbjShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></htzbjCom>
	<!-- 审核对客报价单 -->
	<shdkbjdCom :field_permissions="field_permissions" :show="shdkbjdShow" @close="shdkbjdShow = false" :dataObj="dataObj" @onSuccess="onSuccess" :dkData="dkData"></shdkbjdCom>
	<!-- 提交签订合同 -->
	<tjqdhyCom :show="tjqdhyShow" @close="tjqdhyShow = false" :dataObj="dataObj" @onSuccess="onSuccess" :dkData="dkData" :zjData="zjData"></tjqdhyCom>
	<!-- 提交预付款凭证 -->
	<tjyfkpzCom :show="tjyfkpzShow" @close="tjyfkpzShow = false" :signing_company_data="signing_company_data" :dataObj="dataObj" @onSuccess="onSuccess"></tjyfkpzCom>
	<!-- 预付款确认 -->
	<yfkdkqrCom
		:field_permissions="field_permissions"
		:show="yfkdkqrShow"
		@close="yfkdkqrShow = false"
		:yfkpzData="yfkpzData"
		:dataObj="dataObj"
		@onSuccess="onSuccess"
	></yfkdkqrCom>
	<!-- 确认开始施工 -->
	<qrkssgCom :show="qrkssgShow" @close="qrkssgShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></qrkssgCom>
	<!-- 节点验收 -->
	<jdysCom
		:show="jdysShow"
		@close="jdysShow = false"
		:dataObj="dataObj"
		@onSuccess="onSuccess"
		:jdysFormList="jdysFormList"
		:jdysRuleForm="jdysRuleForm"
		:jdysRules="jdysRules"
		:projectNodesItem="projectNodesItem"
	></jdysCom>
	<!-- 节点验收审核 -->
	<jdysshCom :projectNodesItem="projectNodesItem" :show="jdysshShow" @close="jdysshShow = false" :jdysArrData="jdysArrData" :dataObj="dataObj" @onSuccess="onSuccess"></jdysshCom>
	<!-- 提交进度款凭证 -->
	<tjjdkpzCom
		:projectNodesItem="projectNodesItem"
		:show="tjjdkpzShow"
		@close="tjjdkpzShow = false"
		:signing_company_data="signing_company_data"
		:dataObj="dataObj"
		@onSuccess="onSuccess"
	></tjjdkpzCom>
	<!-- 进度款打款确认 -->
	<jdkdkqrCom :projectNodesItem="projectNodesItem" :show="jdkdkqrShow" @close="jdkdkqrShow = false" :jdkpzData="jdkpzData" :dataObj="dataObj" @onSuccess="onSuccess"></jdkdkqrCom>
	<!-- 施工记录 -->
	<sgjlCom :projectNodesItem="projectNodesItem" :show="sgjlShow" @close="sgjlShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></sgjlCom>
	<!-- 确认增减项 -->
	<qrzjxCom :show="qrzjxShow" @close="qrzjxShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></qrzjxCom>
	<!-- 审核结算单 -->
	<shjsdCom :field_permissions="field_permissions" :show="shjsdShow" @close="shjsdShow = false" :jsdData="jsdData" :dataObj="dataObj" @onSuccess="onSuccess"></shjsdCom>
	<!-- 提交尾款凭证 -->
	<tjwkpzCpm :show="tjwkpzShow" @close="tjwkpzShow = false" :jsdData="jsdData" :signing_company_data="signing_company_data" :dataObj="dataObj" @onSuccess="onSuccess"></tjwkpzCpm>
	<!-- 回退至结算单 -->
	<htzjsdCom :show="xmhtzjsdShow" @close="xmhtzjsdShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></htzjsdCom>
	<!-- 审核尾款信息 -->
	<shwkxxCom :wkxxData="wkxxData" :show="shwkxxShow" @close="shwkxxShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></shwkxxCom>
	<!-- 确认尾款信息 -->
	<qrwkxxCom :wkxxData="wkxxData" :show="qrwkxxShow" @close="qrwkxxShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></qrwkxxCom>
	<!-- 管理员回退项目 -->
	<adminHtCom :adminHtList="adminHtList" :show="adminHtShow" @close="adminHtShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></adminHtCom>
	<!-- 客户项目评价 -->
	<khxmpjCom :show="khxmpjShow" @close="khxmpjShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></khxmpjCom>
	<!-- 项目取消 -->
	<xmqxCom :show="xmqxShow" @close="xmqxShow = false" :dataObj="dataObj" @onSuccess="onSuccess"></xmqxCom>
</template>

<script setup>
import { ref, reactive, toRefs, toRef, getCurrentInstance, onMounted, nextTick } from 'vue';
import { onShow, onLoad, onPageScroll } from '@dcloudio/uni-app';
const { proxy: that } = getCurrentInstance();
onLoad((e) => {
	console.log(e, '页面传递参数');
	data.userInfo = uni.getStorageSync('userInfo');
	getProjectDetails(e.id);
	getOrganizationDetails();
	uni.setNavigationBarColor({
		frontColor: '#000000',
		backgroundColor: '#ffffff',
		animation: {
			duration: 400,
			timingFunc: 'easeIn'
		}
	});
});
// 管理员回退列表
let backOptions2 = [
	{
		label: '客户经理选择是否勘场',
		value: 1010
	},
	{
		label: '客户经理或客户提交设计图',
		value: 1015
	},
	{
		label: '客户经理申请报价',
		value: 1065
	},
	{
		label: '造价主管分配造价员,工程部经理分配工程经理',
		value: 1070
	},
	{
		label: '造价员报价',
		value: 1080
	},
	{
		label: '工程经理审核造价单',
		value: 1090
	},
	{
		label: '造价主管审核造价单',
		value: 1092
	},
	{
		label: '客户经理对客报价',
		value: 1095
	},
	{
		label: '客户总监审核对客报价',
		value: 1100
	},
	{
		label: '客户经理签约合同',
		value: 1102
	},
	{
		label: '客户经理提交预付款信息',
		value: 1105
	},
	{
		label: '财务确认预付款信息',
		value: 1110
	},
	{
		label: '工程监理启动工程',
		value: 1115
	},
	{
		label: '客户经理确认增减项',
		value: 1125
	},
	{
		label: '造价员出具结算单',
		value: 1130
	},
	{
		label: '工程经理审核结算单',
		value: 1135
	},
	{
		label: '造价主管审核结算单',
		value: 1138
	},
	{
		label: '客户经理提交尾款信息',
		value: 1140
	}
];
let backOptions1 = [
	{
		label: '客户经理选择是否勘场',
		value: 1010
	},
	{
		label: '客户经理或客户提交设计图',
		value: 1015
	},
	//  需要勘场-------------
	{
		label: '客户经理提交勘场费用',
		value: 1020
	},
	{
		label: '财务确认勘场费用信息',
		value: 1025
	},
	{
		label: '工程部经理分配工程经理',
		value: 1030
	},
	{
		label: '工程经理提交勘场报告',
		value: 1045
	},
	{
		label: '设计师上传勘场资料',
		value: 1055
	},
	{
		label: '客户经理上传设计图',
		value: 1060
	},
	// 需要勘场------------
	{
		label: '客户经理申请报价',
		value: 1065
	},
	{
		label: '造价主管分配造价员',
		value: 1070
	},
	{
		label: '造价员报价',
		value: 1080
	},
	{
		label: '工程经理审核造价单',
		value: 1090
	},
	{
		label: '造价主管审核造价单',
		value: 1092
	},
	{
		label: '客户经理对客报价',
		value: 1095
	},
	{
		label: '客户总监审核对客报价',
		value: 1100
	},
	{
		label: '客户经理签约合同',
		value: 1102
	},
	{
		label: '客户经理提交预付款信息',
		value: 1105
	},
	{
		label: '财务确认预付款信息',
		value: 1110
	},
	{
		label: '工程监理启动工程',
		value: 1115
	},
	{
		label: '客户经理确认增减项',
		value: 1125
	},
	{
		label: '造价员出具结算单',
		value: 1130
	},
	{
		label: '工程经理审核结算单',
		value: 1135
	},
	{
		label: '造价主管审核结算单',
		value: 1138
	},
	{
		label: '客户经理提交尾款信息',
		value: 1140
	}
];
// 去完善项目
const goToDetail = () => {
	uni.navigateTo({
		url: '/pagesA/add_project/add_project?data=' + JSON.stringify(data.dataObj)
	});
};
// 项目详情
const getProjectDetails = (project_id) => {
	let adminHtListVal = [];
	that.$Api
		.getProjectObj({
			project_id
		})
		.then((res) => {
			console.log(res.data, '项目详情', res.data.status);
			if (res.code == 200) {
				data.dataObj = res.data;
				if (res.data.survey_site == 2) {
					adminHtListVal = backOptions1;
				} else {
					adminHtListVal = backOptions2;
				}
				let delVlaue = [];
				adminHtListVal.forEach((item, index) => {
					if (item.value > res.data.status || item.value == res.data.status) {
						delVlaue.push(item);
					}
				});
				delVlaue.forEach((item) => {
					let index = adminHtListVal.findIndex((child) => {
						return item.value == child.value;
					});
					adminHtListVal.splice(index, 1);
				});
				// 判断当前需要验收的节点
				if (res.data.status == '1120' || res.data.status == '1118') {
					let project_nodes = '';
					for (let i = 0; i < res.data.project_nodes.length; i++) {
						if (res.data.project_nodes[i].node_status != 6) {
							project_nodes = res.data.project_nodes[i];
							break;
						}
					}
					data.projectNodesItem = project_nodes;
					console.log(project_nodes, '当前需执行节点', project_nodes.node_status);
				}
				// 判断是否有可回退节点
				if (res.data.status == 1120 || res.data.status > 1120) {
					let index = adminHtListVal.findIndex((item) => {
						return item.value == 1115;
					});
					index = index + 1;
					res.data.project_nodes.forEach((item) => {
						if (item.node_status > 1) {
							adminHtListVal.splice(index, 0, {
								label: item.node_name,
								value: 1120,
								node_id: item.id
							});
							index = index + 1;
						}
					});
				}
				data.adminHtList = [adminHtListVal];
				console.log(data.adminHtList, '-------------回退列表----------');
				getProjectLogList(project_id);
			}
		});
};
// 日志tab
const tabClick = (e) => {
	getProjectLogList(data.dataObj.id, e.index);
};
// 项目日志
const getProjectLogList = (project_id, log_type) => {
	console.log(log_type, '---------------------', data.log_type);
	uni.showLoading({
		mask: true
	});
	data.logList = [];
	that.$Api
		.getProjectLogList({
			project_id,
			log_type: log_type != undefined ? log_type : data.log_type
		})
		.then((res) => {
			console.log(res, '项目日志');
			uni.hideLoading();
			if (res.code == 200) {
				res.data.forEach((item) => {
					if (item.form_data) {
						item.form_data = JSON.parse(item.form_data);
						// 拿到最新一条尾款数据（审核用）
						if (item.log_status == 410 && !data.wkxxData) {
							data.wkxxData = item.form_data;
						}
						// 拿最新一条结算单数据（审核用）
						if (item.log_status == 380 && !data.jsdData) {
							data.jsdData = item.form_data;
						}
						// 拿最新一条进度款数据（审核用）
						if (item.log_status == 350 && !data.jdkpzData) {
							data.jdkpzData = item.form_data;
						}
						// 拿最新提交节点（审核用）
						if (item.log_status == 320 && !data.jdysArrData) {
							data.jdysArrData = item.form_data.nodes;
						}
						// 拿项目预付款信息
						if (item.log_status == 290 && !data.yfkpzData) {
							data.yfkpzData = item.form_data;
						}
						// 拿合同的签约账户（后续需要继承）
						if (item.log_status == 280 && !data.signing_company_data) {
							data.signing_company_data = item.form_data;
						}
						// 财务确认勘场费用凭证（获取最新一条勘场凭证财务审核时展示）
						if (item.log_status == 140 && !data.shkxpzData) {
							data.shkxpzData = item.form_data;
						}
						// 最新一条对客报价数据
						if (!data.dkData && item.log_status == 250) {
							data.dkData = {
								old_amount: item.form_data.old_amount,
								new_amount: item.form_data.new_amount,
								discount_amount: item.form_data.discount_amount,
								remark: item.form_data.remark
							};
						}
						// 拿到最新一条造价数据
						if (!data.zjData && item.log_status == 220) {
							data.zjData = item.form_data;
						}
					}
				});
				data.logList = res.data;
				data.log_type = log_type == undefined ? data.log_typelog_type : log_type;
			}
		})
		.catch((err) => {
			uni.hideLoading();
		});
};
// 字段权限列表
const getOrganizationDetails = () => {
	data.field_permissions = {};
	that.$Api
		.getOrganizationDetails({
			id: data.userInfo.position_id
		})
		.then((res) => {
			console.log(res, '字段权限列表');
			if (res.code == 200) {
				if (!res.data[0].field_permissions) return;
				JSON.parse(res.data[0].field_permissions).forEach((item) => {
					for (let i in item.field_list) {
						data.field_permissions[i] = item.field_list[i];
					}
				});
				console.log(data.field_permissions, '所有权限列表');
			}
		});
};
// 判断是否显示
const fieldShowFunc = (field) => {
	return data.field_permissions[field] == undefined ? true : data.field_permissions[field];
};
const navToDetail = () => {
	let path = '/pagesA/project_detail/project_detail?data=' + data.dataObj.id;
	uni.navigateTo({
		url: path
	});
};
const data = reactive({
	fpkhjlShow: false,
	tjkcpzShow: false,
	userInfo: '',
	dataObj: {},
	logList: [],
	pagScroll(e) {},
	scrollTop: 0,
	dkData: '', //最新一条对客报价数据
	zjData: '', //最新一条造价数据
	projectNodesItem: '', //需要验收的节点F
	dkrzShow: false,
	kcfdkqrShow: false,
	fkgcjlShow: false,
	tjkcbgShow: false,
	scsjtShow: false,
	sqbjShow: false,
	fpzjyShow: false,
	shzjdShow: false,
	jjjdShow: false,
	dkbjShow: false,
	htzbjShow: false,
	shdkbjdShow: false,
	tjqdhyShow: false,
	tjyfkpzShow: false,
	yfkdkqrShow: false,
	qrkssgShow: false,
	xmqxShow: false,
	jdysShow: false,
	// 节点验收
	jdysRuleForm: {},
	jdysFormList: [],
	jdysRules: {},
	jdysshShow: false,
	tjjdkpzShow: false,
	jdkdkqrShow: false,
	sgjlShow: false,
	qrzjxShow: false,
	shjsdShow: false,
	tjwkpzShow: false,
	xmhtzjsdShow: false,
	qrwkxxShow: false,
	adminHtList: [],
	adminHtShow: false,
	khxmpjShow: false,
	sckczlShow: false,
	shwkxxShow: false,
	tabList: [
		{
			name: '全部'
		},
		{
			name: '勘场记录'
		},
		{
			name: '报价记录'
		},
		{
			name: '合同记录'
		},
		{
			name: '施工记录'
		},
		{
			name: '收尾记录'
		}
	],
	field_permissions: {},
	log_type: 0,
	shkxpzData: '',
	signing_company_data: '',
	yfkpzData: '',
	jdysArrData: '',
	jdkpzData: '',
	jsdData: '',
	wkxxData: ''
});
let {
	wkxxData,
	jsdData,
	jdkpzData,
	jdysArrData,
	yfkpzData,
	signing_company_data,
	shkxpzData,
	pagScroll,
	scrollTop,
	userInfo,
	logList,
	dataObj,
	fpkhjlShow,
	tjkcpzShow,
	dkrzShow,
	kcfdkqrShow,
	fkgcjlShow,
	tjkcbgShow,
	scsjtShow,
	sqbjShow,
	fpzjyShow,
	shzjdShow,
	jjjdShow,
	dkbjShow,
	htzbjShow,
	shdkbjdShow,
	dkData,
	tjqdhyShow,
	zjData,
	tjyfkpzShow,
	yfkdkqrShow,
	qrkssgShow,
	xmqxShow,
	projectNodesItem,
	jdysShow,
	jdysRuleForm,
	jdysFormList,
	jdysRules,
	jdysshShow,
	tjjdkpzShow,
	jdkdkqrShow,
	sgjlShow,
	qrzjxShow,
	shjsdShow,
	tjwkpzShow,
	xmhtzjsdShow,
	qrwkxxShow,
	adminHtList,
	adminHtShow,
	khxmpjShow,
	tabList,
	field_permissions,
	log_type,
	sckczlShow,
	shwkxxShow
} = toRefs(data);

const onRefresh = () => {
	getProjectDetails(data.dataObj.id);
	setTimeout(() => {
		that.$refs.paging.complete([]);
	}, 500);
};
// 操作成功回调
const onSuccess = () => {
	data.fpkhjlShow = false; //分配客户经理
	data.tjkcpzShow = false; //提交勘场凭证
	data.dkrzShow = false; //对客日志
	data.kcfdkqrShow = false; //勘场费确认
	data.fkgcjlShow = false; //分配工程经理
	data.tjkcbgShow = false; //提交勘场报告
	data.sckczlShow = false; //上传勘场资料
	data.scsjtShow = false; //上传设计图
	data.sqbjShow = false; //申请报价
	data.fpzjyShow = false; //分配造价员
	data.shzjdShow = false; //审核造价单
	data.jjjdShow = false; //拒绝接单（工程经理）
	data.dkbjShow = false; //对客报价
	data.htzbjShow = false; //回退至报价
	data.shdkbjdShow = false; //审核对客报价单
	data.tjqdhyShow = false; //提交签订合同
	data.tjyfkpzShow = false; //提交预付款凭证
	data.yfkdkqrShow = false; //预付款打款确认
	data.qrkssgShow = false; //确认开始施工
	data.xmqxShow = false; //项目取消
	data.jdysShow = false; //节点验收
	data.jdysshShow = false; //节点验收审核
	data.tjjdkpzShow = false; //提交进度款凭证
	data.jdkdkqrShow = false; //进度款打款确认
	data.sgjlShow = false; //施工记录
	data.qrzjxShow = false; //确认增减项
	data.shjsdShow = false; //审核结算单
	data.tjwkpzShow = false; //提交尾款信息
	data.xmhtzjsdShow = false; //项目回退至结算单
	data.shwkxxShow = false; //审核尾款信息
	data.qrwkxxShow = false; //确认尾款信息
	data.adminHtShow = false; //管理员回退项目
	data.khxmpjShow = false; //客户项目评价
	getProjectDetails(data.dataObj.id);
};
// 暴露方法   其他页面方便调用
defineExpose({
	getProjectDetails, //将需要调用的方法暴露在当前实例上
	data
});
// 节点验收
const jdysShouwFunc = () => {
	let projectNodesItem = data.projectNodesItem;
	let children = projectNodesItem.children;
	// console.log(projectNodesItem.children, '节点', projectNodesItem);
	let jdysRuleForm = {};
	let jdysFormList = [];
	let jdysRules = {};

	children.forEach((item) => {
		let formName = '';
		let obj = {
			name: item.node_name,
			is_required: item.is_required,
			content_type: item.content_type
		};
		if (item.content_type == 1) {
			// 文本
			formName = `content_${item.id}`;
			jdysRuleForm[formName] = '';
		} else {
			// 图片视频
			formName = `file_${item.id}`;
			jdysRuleForm[formName] = [];
		}
		obj.prop = formName;
		if (item.is_required == 1) {
			if (item.content_type == 1) {
				// 文本
				jdysRules[formName] = [
					{
						required: true,
						message: '请输入内容',
						trigger: ['blur', 'change']
					}
				];
			} else {
				// 文件
				jdysRules[formName] = {
					required: true,
					asyncValidator: ysjdFile,
					trigger: ['blur', 'change']
				};
			}
		}
		jdysFormList.push(obj);
	});
	jdysRuleForm.remark = '';
	// console.log(jdysFormList, 'jdysFormList');
	data.jdysFormList = jdysFormList; //formitem
	data.jdysRuleForm = jdysRuleForm; //填写数据
	data.jdysRules = jdysRules; //验证是否必填
	nextTick(() => {
		data.jdysShow = true;
	});
};
//
const ysjdFile = (rule, value, callback) => {
	if (!value.length) {
		callback(new Error('请上传文件'));
	} else {
		callback();
	}
};
const leftClick = () => {
	// 获取当前页面栈数组
	const pages = getCurrentPages();
	// 获取栈顶页面的实例
	const prevPage = pages[pages.length - 2]; //上一页
	if (!prevPage) {
		uni.reLaunch({
			url: '/pages/index/index'
		});
	} else {
		uni.navigateBack();
	}
	console.log('返回上一页', prevPage);
};
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
